from rest_framework import serializers
from .models import Area

class AreaSerializer(serializers.ModelSerializer):
    """省/市/区一个个的序列化器"""

    class Meta:
        model = Area
        fields = ['id', 'name']

class SubsAreaSerializer(serializers.ModelSerializer):
    """省和市的单一序列化器"""
    subs = AreaSerializer(many=True, read_only=True)
    class Meta:
        model = Area
        fields = ['id','name', 'subs']